import { Controller, Get, Post, Body, Patch, Param, Delete, Query, UseGuards } from '@nestjs/common'
import { RewardService } from './reward.service'
import { CreateRewardDto } from './dto/create-reward.dto'
import { UpdateRewardDto } from './dto/update-reward.dto'
import { AuthGuard } from '@nestjs/passport'

@Controller('reward')
@UseGuards(AuthGuard('jwt'))
export class RewardController {
    constructor(private readonly rewardService: RewardService) { }

    @Post()
    create(@Body() createRewardDto: CreateRewardDto) {
        return this.rewardService.create(createRewardDto);
    }

    @Get()
    findAll(@Query() urlQuery: { pageIndex: string, pageSize: string }) {
        const query = {
            pageIndex: +urlQuery.pageIndex,
            pageSize: +urlQuery.pageSize
        }
        return this.rewardService.findAll(query)
    }

    @Get(':id')
    findOne(@Param('id') id: string) {
        return this.rewardService.findOne(+id)
    }

    @Patch(':id')
    update(@Param('id') id: string, @Body() updateRewardDto: UpdateRewardDto) {
        return this.rewardService.update(+id, updateRewardDto)
    }

    @Delete(':id')
    remove(@Param('id') id: string) {
        return this.rewardService.remove(+id)
    }
}
